package com.example.graduate.conf.mybatis;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;


@Configuration
public class MybatisConfiguration {
//    @Bean
//    public SqlSessionFactory sqlSessionFactory() throws Exception {
//        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
//        sqlSessionFactoryBean.setMapperLocations(new PathResource("classpath:mappers/*.xml"));
//        sqlSessionFactoryBean.setDataSource(dataSource());
//        return sqlSessionFactoryBean.getObject();
//    }

    @Bean
    public DataSource dataSource(){
        DataSourceBuilder sourceBuilder = DataSourceBuilder.create();
        sourceBuilder.username("root");
        sourceBuilder.password("123456");
        sourceBuilder.driverClassName("com.mysql.cj.jdbc.Driver");
        sourceBuilder.url("jdbc:mysql://47.100.177.88:3306/graduate?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC");
        return sourceBuilder.build();
    }
}
